//  This is the input and output script for the Helixoide SlServ Device
//  It implements the Helixoide SlServ protocol for Version 1.5
//  Current Implementation is based on irc.helixoide.com (DarkDna irc network)
//  If you want to help Develop contact Ross D. at posiden@helixoide.com

//  Helixoide Solarian Sl-Status system: in/out.lsl
//  Based On The Helixoide SlServ Device 1.5 beta 2
//  Created by Ross Delinger (aka: Posiden Dryke)
//  Last Update: Sunday 28th of Feburary 2010 11:39AM EST
//  SlServ Requirments: Helixoide SLServ 1.5
//  SlServ Code can be Found on http://code.google.com

sendChatToIRC(string user, string chat)
{
    if(chat!="")
    {
        list tokens = [(string)llGetKey(),"PRIVMSG",user,chat];
        string theMsg = llDumpList2String(tokens,"&");
        llMessageLinked(LINK_SET,1337,theMsg,"MSG");
    }
}    
string formatName(string name)
{
    list seperated = llParseString2List(name,[" "],[]);
    seperated = ["SL"] + seperated;
    string nick = llDumpList2String(seperated,"-");
    return nick;
    
}
string myName;
default
{
    state_entry()
    {
        llListen(0,"","","");
    }
    listen(integer c, string n, key id, string msg)
    {
        sendChatToIRC(formatName(n),msg);
        
    }
    link_message(integer snum, integer num, string str, key id)
    {
        if((string)id == "PRIVMSG")
        {
            myName = llGetObjectName();
            list temp = llParseString2List(str,["|"],[]);
            string user = llList2String(temp,1);
            string msg = llList2String(temp,0);
            llSetObjectName(user);
            llSay(0, msg);
            llSetObjectName(myName);
        }
    }

   
}
